<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class View extends CI_Controller {

	function View(){
		parent::__construct();
		
		$this->load->model('cms_model');
		$this->load->helper('security');		
	}
	
	public function index(){
		//param
		$sid = $this->uri->segment(3);
		if(empty($sid))
			$sid = 's_001';
		
		//find template
		$tarray = $this->cms_model->findtemplate($sid, 0);
		$tid = $tarray['tid'];
		$tcontent = $tarray['content'];
		$sid = $tarray['sid'];
		
		if(empty($tcontent))
			return ;
		
		/*---the data to view---*/
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
		
		//图片新闻
		$data['picnews']= $this->cms_model->getpicnews( 0);
		
		//领导简介
		$data['leaders']= $this->cms_model->getleaders( 0);
		
		//机关建设
		$data['jiguan']= $this->cms_model->listsubcolumnsbycname('机关建设', 0);
		
		//处室子站
		$data['chushi']= $this->cms_model->listChuShi(0,'');		
		
		//商务新闻
		$data['biznews']= $this->cms_model->listcolarticlesbycname('商务新闻',1, 7, 0);
		$data['linkbiznews'] = $this->cms_model->getcollinkbyname('商务新闻', 0);
		
		//工作动态
		$data['dongtai']= $this->cms_model->listcolarticlesbycname('工作动态',1, 7, 0);
		$data['linkdongtai'] = $this->cms_model->getcollinkbyname('工作动态', 0);
		
		//领导讲话
		$data['lingdao']= $this->cms_model->listcolarticlesbycname('领导讲话',1, 6, 0);
		$data['linklingdao'] = $this->cms_model->getcollinkbyname('领导讲话', 0);
		
		//通知公告
		$data['tongzhi']= $this->cms_model->listcolarticlesbycname('通知公告',1, 6, 0);
		$data['linktongzhi'] = $this->cms_model->getcollinkbyname('通知公告', 0);
		
		//商务重要信息
		$data['bizzhongyao']= $this->cms_model->listcolarticlesbycname('商务重要信息',1, 6, 0);
		$data['linkbizzhongyao'] = $this->cms_model->getcollinkbyname('商务重要信息', 0);
		
		//商务简报
		$data['bizjianbao']= $this->cms_model->listcolarticlesbytag('swjb',1, 6, 0);
		$data['linkbizjianbao'] = $this->cms_model->getcollinkbytag('swjb', 0);
		
		//治庸问责
		$data['zhiyong']= $this->cms_model->getcollinkbyname('治庸问责', 0);
		
		//专题专栏
		$data['zhuanti']= $this->cms_model->listsubcolumnsbytag_pic('专题专栏', 0);
		
		//会展信息
		$data['huizhan']= $this->cms_model->listcolarticlesbycname('会展信息',1, 6, 0);
		$data['linkhuizhan'] = $this->cms_model->getcollinkbyname('会展信息', 0);
		
		//市州商务
		$data['shizhou']= $this->cms_model->listcolarticlesbycname('市州商务',1, 6, 0);
		$data['linkshizhou'] = $this->cms_model->getcollinkbyname('市州商务', 0);
		
		//统计分析 / 统计数据查询 
		$data['tongji']= $this->cms_model->listcolarticlesbycname('统计分析',1, 6, 0);
		$data['linktongji'] = $this->cms_model->getcollinkbyname('统计分析', 0);
		
		//政策规范 / 政策解读 
		$data['zhengce']= $this->cms_model->listcolarticlesbycname('政策规范',1, 6, 0);
		$data['linkzhengce'] = $this->cms_model->getcollinkbyname('政策规范', 0);
		
		$data['zhengcejiedu']= $this->cms_model->listcolarticlesbycname('政策解读',1, 6, 0);
		$data['linkzhengcejiedu'] = $this->cms_model->getcollinkbyname('政策解读', 0);
		
		//全省主要生活必需品价格
		$data['pricetitle'] = '';
		$data['pricetable'] = '';
		$pricearray = $this->cms_model->getlastprice(0);
		if( is_array($pricearray)){
			foreach ($pricearray as $price){
				$data['pricetitle'] = $price['title'];
				$data['pricetable'] = str_replace('&nbsp;', ' ',$price['acontent']) ;
			}
		}
		$data['linkpricetitle'] = $this->cms_model->getlastpricelink(0);
		
		//政府信息公开
		$data['zfxxgk']= $this->cms_model->listsubcolumnsbycname('政府信息公开', 0, '');
		
		//网上办事
		$data['linkfiledownload']= $this->cms_model->getcollinkbytag('download_file', 0);
		$data['linkgriddownload']= $this->cms_model->getcollinkbytag('download_grid', 0);
		$data['linkdzjc']= "http://202.110.133.70/xzspwebred/cmsPagePub/XxBanjieAction.do?operate=xxBanjieList&operPage=spjg2&deptid=010890537";//$this->cms_model->getcollinkbytag('dzjc', 0);
		
		//公众互动
		$data['linkmyzj']= $this->cms_model->getcollinkbytag('myzj', 0);
		$data['linkzxft']= $this->cms_model->getcollinkbytag('zxft', 0);
		$data['linkgzsq']= $this->cms_model->getcollinkbytag('gzsq', 0);		
		
		//商务视频
		$data['linkvideo']= $this->cms_model->getcollinkbyname('商务视频', 0);
		
		//行业建设与发展
		$data['linkdiaoyan']= $this->cms_model->getcollinkbytag('diaoyan', 0);
		$data['linkbmdt']= $this->cms_model->getcollinkbytag('bmdt', 0);
		
		//湖北省商务概况
		$data['gaikuang']= $this->cms_model->listcolarticlesbycname('湖北商务概览',1, 4, 0);
		
		//进出口数据
		$data['linkjck'] = '';
		$data['jckpic'] = '';
		$jck = $this->cms_model->getfirstartbycname_pic('进出口数据', 0);
		foreach ($jck as $key=>$value){
			$data['linkjck'] = $key;
			$data['jckpic'] = $value;
		}
		
		/*----------------------*/		
		
		//view by smarty
		$tplfilename = $tid.'.tpl';
		$this->smarty->view($tplfilename,$data,False);		
		//$output = $this->smarty->view($tplfilename,$data,True);
		//echo ($output);
	}
	
	public function col(){
		//param
		$cid = $this->uri->segment(3);
		$pagenum = $this->uri->segment(4);
		
		//find template
		$sid = '';
		$tid='';
		$tcontent = '';
		$tarray = $this->cms_model->findtemplate($cid, 0);
		$tid = $tarray['tid'];
		$tcontent = $tarray['content'];
		$sid = $tarray['sid'];
		if(empty($tcontent))
			return ;
			
		/*---the data to view---*/
			
		$data['cid'] = $cid;
			
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
						
		//nav column
		$navcolarray = $this->cms_model->getnavcols($cid,0);
		$data['navcolarray'] = $navcolarray;
		
		//column name
		$colname = $this->cms_model->getcolname($cid);
		$data['colname'] = $colname;	
		
		//sub columns
		$data['subcol'] = $this->cms_model->listsubcolumns($cid, 0);
		
		//has child
		$data['haschild'] = $this->cms_model->hasChildColumns($cid);
		
		//click number
		$data['articles_click'] = $this->cms_model->getartofclicknum($cid, 0);
		
		//articles
		if(empty($pagenum))
			$pagenum = 1;
		$pagesize = 15;		
		$start = $pagesize * ($pagenum-1);		
		$data['articles'] = $this->cms_model->listcolarticles($cid, $pagenum, $pagesize, 0);
		
		//pager
		$pagecount = $this->cms_model->getartpagecount($cid, $pagesize);	
		$pager = $this->cms_model->GetPagerHtml($pagenum,$pagecount);
		$data['pager'] = $pager;
		
		if($colname == '主要职责' || $colname == '机构设置'){
			//单页面数据
			//$tcontent = '';
			$atitle='';
			$acontent = '';
			$atype = '';
			$updatetime = '';
			$clicknum = 0;
			
			$sql = "select * from qf_article where cid='$cid' and disabled=0 and display=0 and astatus=1 order by sortno, updatetime desc limit 1";
			$query = $this->db->query($sql);
			if($query->num_rows() > 0){
				$row = $query->row();
				//$sid = $row->sid;
				//$tid = $row->templateid;
				$acontent = $row->acontent;
				$author = $row->author;
				$updatetime = $row->updatetime;
				$atype = $row->atype;
				//$cid = $row->cid;
				$atitle = $row->title;
				$clicknum = $row->clicknum;
			}
			
			$data['acontent'] = $acontent;
			$data['author'] = $author;
			$data['updatetime'] =  date('Y年m月d日', strtotime($updatetime));
			$data['atitle'] = $atitle;
			$data['clicknum'] = $clicknum;			
		}
		
		/*----------------------*/		
		
		//view by smarty
		$tplfilename = $tid.'.tpl';
		$this->smarty->view($tplfilename,$data,False);
	}
	
	public function art(){
		//param
		$aid = $this->uri->segment(3);
		
		/*---the data to view---*/
		
		$sid = '';
		$cid = '';
		$tid='';
		$tcontent = '';
		$atitle='';
		$acontent = '';
		$atype = '';
		$updatetime = '';
		$clicknum = 0;
		
		$sql = "select * from qf_article where aid='$aid'";
		$query = $this->db->query($sql);
		if($query->num_rows() > 0){
			$row = $query->row();
			$sid = $row->sid;
			$tid = $row->templateid;
			$acontent = $row->acontent;
			$author = $row->author;
			$updatetime = $row->updatetime;
			$atype = $row->atype;
			$cid = $row->cid;
			$atitle = $row->title;
			$clicknum = $row->clicknum;
		}
		
		$data['acontent'] = $acontent;
		$data['author'] = $author;
		$data['updatetime'] =  date('Y年m月d日', strtotime($updatetime));
		$data['atitle'] = $atitle;
		$data['clicknum'] = $clicknum;
		
		//update clicknum
		$clicknum ++;
		$sql = "update qf_article set clicknum='$clicknum' where aid='$aid'";
		$this->db->query($sql);
		
		//find template
		$tarray = $this->cms_model->findtemplate($aid, 0);
		if(is_array($tarray)){
		$tid = $tarray['tid'];
		$tcontent = $tarray['content'];
		$sid = $tarray['sid'];
		}
		
		if(empty($tcontent))
			return ;
			
		$data['cid'] = $cid;
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
						
		//nav column
		$navcolarray = $this->cms_model->getnavcols($cid,0);
		$data['navcolarray'] = $navcolarray;
		
		//column name
		$colname = $this->cms_model->getcolname($cid);
		$data['colname'] = $colname;
		
		//相关信息
		$data['articles_click'] = $this->cms_model->getartofclicknum($cid, 0);
		
		//更多
		$data['linkartmore'] = "/view/col/".$cid;
		
		//相关文章
		$data['aboutlist'] = $this->cms_model->listartabout($aid, 0);		
		
		//附件
		$data['attlist'] = $this->cms_model->listArticleAtts($aid);		
		
		/*----------------------*/		
		
		//view by smarty
		$tplfilename = $tid.'.tpl';
		$this->smarty->view($tplfilename,$data,False);
	}
	
	public function govsystemlist(){
		$sid = 's_001';
		//today
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
						
		//nav column
		//$navcolarray = $this->cms_model->getnavcols($cid,0);
		//$data['navcolarray'] = $navcolarray;
		
		//column name
		//$colname = $this->cms_model->getcolname($cid);
		//$data['colname'] = $colname;
		
		
		$this->load->view('header_view',$data);
		$this->load->view('govsystemlist_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function drawVC()
	{		
		$this->load->library('captchaimage');
		
		//session_start();
		
		$flag = $this->uri->segment(3);
        if(empty($flag))
        	$flag = 'zixun';
        
        ob_start();
        
        //write session
            
        //$this->session->userdata('vcode') =  $vc;
        //$newdata = array('vcode'  => $vc);
		//$this->session->set_userdata($newdata);
		//$_SESSION['zixuncode'] = $vc;
		$vc = $this->captchaimage->getString();    
        //$this->session->userdata('zixuncode') = $vc;
        
        $newdata = array($flag  => $vc);
        
		$this->session->set_userdata($newdata);
        
        $this->captchaimage->setFont('./fonts/1.ttf',20);     
        $this->captchaimage->draw();  
              
        ob_flush();
        
	}
	
	public function zixun(){
		$sid = 's_001';
		$pagenum = $this->uri->segment(3);
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);

		//历史咨询
		$pagesize = 15;
		if(empty($pagenum))
			$pagenum = 1;	
		$start = $pagesize * ($pagenum-1);
		
		$sql = 'select * from consultation where checked=1 order by replyTime desc';
		$sql .=" limit ".$start.",".$pagesize;
		$query = $this->db->query($sql);
		$data['history'] = $query->result_array();
		
		$pagecount = 0;
		$rownum = 0;
		$sql = "select count(*) as c from consultation where checked=1 ";
		$querycount = $this->db->query($sql);
		if($querycount->num_rows() > 0){
			$row = $querycount->row();
			$rownum = $row->c;
		}
		$pagecount = ceil($rownum / $pagesize);			
		$pager = $this->cms_model->GetPagerHtml($pagenum,$pagecount);
		$data['pager']=$pager;
		
		$this->load->view('header_view',$data);
		$this->load->view('zixun_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function tousu(){
		$sid = 's_001';
		$pagenum = $this->uri->segment(3);
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);

		//
		$this->load->view('header_view',$data);
		$this->load->view('tousu_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function vote(){
		$sid = 's_001';
		$pagenum = $this->uri->segment(3);
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);

		//最后一次投票(标题,投票项,起始时间,id,multiSelect)
		$voteid = '';
		$data['voteid'] = '';
		$data['votetitle'] = '';
		$data['votelines'] = '';
		$data['multiSelect'] = '';
		$data['votetime'] = '';
		$sql = "select * from voteitem order by postTime desc limit 1";
		$query = $this->db->query($sql);
		if($query->num_rows() > 0){
			$row = $query->row();
			$voteid = $row->id;
			$data['voteid'] = $row->id;
			$data['votetitle'] = $row->content;
			$data['multiSelect'] = $row->multiSelect;
			$data['votetime'] = date('Y年m月d日', strtotime($row->startDate))." 至 ".date('Y年m月d日', strtotime($row->endDate));
		}
		$sql = "select * from votelineitem where vote_item_id='$voteid'";
		$query = $this->db->query($sql);
		$data['votelines'] = $query->result_array();
		
		//历史投票结果
		$sql = "select * from voteitem where open='1' order by postTime desc limit 10";
		$query = $this->db->query($sql);
		$data['votehistory'] = $query->result_array();
		
		$this->load->view('header_view',$data);
		$this->load->view('vote_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function votepost(){
		
	}
	
	public function voteresult(){
		
	}
	
	public function sitemap(){
		$sid = 's_001';
		
		//
		$list1 = array();
				
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		$menucols = $this->cms_model->listmenucols($sid, 'menu', 0);
		foreach ($menucols as $key=>$value){
			$list1[$key] = $value;
		}
		
		//网上公示 menu link
		
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
		
		$list1[$data['linkpubnews']] = "网上公示";
		$list1[$data['linkfaq']] = "常见问题";
		
		//商务新闻
		//$data['biznews']= $this->cms_model->listcolarticlesbycname('商务新闻',1, 7, 0);
		$data['linkbiznews'] = $this->cms_model->getcollinkbyname('商务新闻', 0);
		$list1[$data['linkbiznews']] = "商务新闻";
		
		//工作动态
		//$data['dongtai']= $this->cms_model->listcolarticlesbycname('工作动态',1, 7, 0);
		$data['linkdongtai'] = $this->cms_model->getcollinkbyname('工作动态', 0);
		$list1[$data['linkdongtai']] = "工作动态";
		
		//领导讲话
		//$data['lingdao']= $this->cms_model->listcolarticlesbycname('领导讲话',1, 6, 0);
		$data['linklingdao'] = $this->cms_model->getcollinkbyname('领导讲话', 0);
		$list1[$data['linklingdao']] = "领导讲话";
		
		//通知公告
		//$data['tongzhi']= $this->cms_model->listcolarticlesbycname('通知公告',1, 6, 0);
		$data['linktongzhi'] = $this->cms_model->getcollinkbyname('通知公告', 0);
		$list1[$data['linktongzhi']] = "通知公告";
		
		//商务重要信息
		//$data['bizzhongyao']= $this->cms_model->listcolarticlesbycname('商务重要信息',1, 6, 0);
		$data['linkbizzhongyao'] = $this->cms_model->getcollinkbyname('商务重要信息', 0);
		$list1[$data['linkbizzhongyao']] = "商务重要信息";
		
		//商务简报
		//$data['bizjianbao']= $this->cms_model->listcolarticlesbytag('swjb',1, 6, 0);
		$data['linkbizjianbao'] = $this->cms_model->getcollinkbytag('swjb', 0);
		$list1[$data['linkbizjianbao']] = "商务简报";
		
		//治庸问责
		$data['zhiyong']= $this->cms_model->getcollinkbyname('治庸问责', 0);
		$list1[$data['zhiyong']] = "治庸问责";
		
		//专题专栏
		//$data['zhuanti']= $this->cms_model->listsubcolumnsbytag_pic('专题专栏', 0);
		
		//会展信息
		//$data['huizhan']= $this->cms_model->listcolarticlesbycname('会展信息',1, 6, 0);
		$data['linkhuizhan'] = $this->cms_model->getcollinkbyname('会展信息', 0);
		$list1[$data['linkhuizhan']] = "会展信息";
		
		//市州商务
		//$data['shizhou']= $this->cms_model->listcolarticlesbycname('市州商务',1, 6, 0);
		$data['linkshizhou'] = $this->cms_model->getcollinkbyname('市州商务', 0);
		$list1[$data['linkshizhou']] = "市州商务";
		
		//统计分析 / 统计数据查询 
		//$data['tongji']= $this->cms_model->listcolarticlesbycname('统计分析',1, 6, 0);
		$data['linktongji'] = $this->cms_model->getcollinkbyname('统计分析', 0);
		$list1[$data['linktongji']] = "统计分析";
		
		//政策规范 / 政策解读 
		//$data['zhengce']= $this->cms_model->listcolarticlesbycname('政策规范',1, 6, 0);
		$data['linkzhengce'] = $this->cms_model->getcollinkbyname('政策规范', 0);
		$list1[$data['linkzhengce']] = "政策规范";
		
		//$data['zhengcejiedu']= $this->cms_model->listcolarticlesbycname('政策解读',1, 6, 0);
		$data['linkzhengcejiedu'] = $this->cms_model->getcollinkbyname('政策解读', 0);
		$list1[$data['linkzhengcejiedu']] = "政策解读";
		//全省主要生活必需品价格
		
		//政府信息公开
		//$data['zfxxgk']= $this->cms_model->listsubcolumnsbycname('政府信息公开', 0, '');
		
		//网上办事
		$data['linkfiledownload']= $this->cms_model->getcollinkbytag('download_file', 0);
		$data['linkgriddownload']= $this->cms_model->getcollinkbytag('download_grid', 0);
		$data['linkdzjc']= "http://202.110.133.70/xzspwebred/cmsPagePub/XxBanjieAction.do?operate=xxBanjieList&operPage=spjg2&deptid=010890537";//$this->cms_model->getcollinkbytag('dzjc', 0);
		
		$list1[$data['linkfiledownload']] = "文件下载";
		$list1[$data['linkgriddownload']] = "表格下载";
		$list1[$data['linkdzjc']] = "电子监察";
		
		//公众互动
		$data['linkmyzj']= $this->cms_model->getcollinkbytag('myzj', 0);
		$data['linkzxft']= $this->cms_model->getcollinkbytag('zxft', 0);
		$data['linkgzsq']= $this->cms_model->getcollinkbytag('gzsq', 0);	

		$list1[$data['linkmyzj']] = "民意征集";
		$list1[$data['linkzxft']] = "在线访谈";
		$list1[$data['linkgzsq']] = "公众诉求";
		
		//商务视频
		$data['linkvideo']= $this->cms_model->getcollinkbyname('商务视频', 0);
		$list1[$data['linkvideo']] = "商务视频";
		
		//行业建设与发展
		$data['linkdiaoyan']= $this->cms_model->getcollinkbytag('diaoyan', 0);
		$data['linkbmdt']= $this->cms_model->getcollinkbytag('bmdt', 0);
		
		$list1[$data['linkdiaoyan']] = "商务调研";
		$list1[$data['linkbmdt']] = "部门动态";
		
		//湖北省商务概况
		//$data['gaikuang']= $this->cms_model->listcolarticlesbycname('湖北商务概览',1, 4, 0);
		
		//进出口数据
//		$data['linkjck'] = '';
//		$data['jckpic'] = '';
//		$jck = $this->cms_model->getfirstartbycname_pic('进出口数据', 0);
//		foreach ($jck as $key=>$value){
//			$data['linkjck'] = $key;
//			$data['jckpic'] = $value;
//		}

		
		
		
		$result = '';
		$i = 0;
		$newtr = true;
		$tdnum = 0;
		foreach ($list1 as $key=>$value) {
			if($newtr){
				$result.="<tr >";
				$newtr = false;
			}
			$result.="<td ><a href=\"".$key."\" target=\"_blank\">".$value."</a></td>";
			$tdnum ++;
			if($tdnum == 5){
				$result.="</tr>";
				$tdnum = 0;
				$newtr = true;
			}
			else{
				if($i == count($list1)-1){
					$j = $i%5;
					for($k=0;$k<$j;$k++)
						$result.="<td></td>";
					$result.="</tr>";
				}
			}
			$i++;
		}
		$data['list1'] = $result;
		
		//处室子站
		$chushi  = $this->cms_model->listsubcolumnsbycname('处室子站',0,'');
		
		$result2 = '';
		$i = 0;
		$newtr = true;
		$tdnum = 0;
		foreach ($chushi as $key=>$value) {
			if($newtr){
				$result2.="<tr >";
				$newtr = false;
			}
			$result2.="<td ><a href=\"".$key."\" target=\"_blank\">".$value."</a></td>";
			$tdnum ++;
			if($tdnum == 5){
				$result2.="</tr>";
				$tdnum = 0;
				$newtr = true;
			}
			else{
				if($i == count($chushi)-1){
					$j = $i%5;
					for($k=0;$k<$j;$k++)
						$result2.="<td></td>";
					$result2.="</tr>";
				}
			}
			$i++;
		}
		$data['list2'] = $result2;
		
		$this->load->view('header_view',$data);
		$this->load->view('sitemap_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function tingzhangmail(){
		$sid = 's_001';
		$pagenum = $this->uri->segment(3);
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
		
		//click number
		$data['articles_click'] = $this->cms_model->getartofclicknum('c_001', 0);
		
		$this->load->view('header_view',$data);
		$this->load->view('tingzhangmail_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function pubsearch(){
		$sid = 's_001';
		$keyword = $_POST['keyword'];
		
		$pagenum= 0;
		if(!empty($_POST['pagenum']))
		$pagenum = $_POST['pagenum']; // $this->uri->segment(3);
		
		$data['keyword'] = $keyword;
		$data['pagenum'] = $pagenum;
		
		if(empty($pagenum))
			$pagenum = 1;
		
		//today
		$data['today'] = $this->cms_model->gettodayandweekstr();
		
		//menu columns
		$data['menucols'] = $this->cms_model->listmenucols($sid, 'menu', 0);
		
		//网上公示 menu link
		$data['linkpubnews']= $this->cms_model->getcollinkbytag('menu_gongshi', 0);
		$data['linkfaq']= $this->cms_model->getcollinkbytag('menu_faq', 0);
		
		//result
		if(!empty($keyword)){
			$keyword = $this->security->xss_clean($keyword);		
			$pagesize = 15;		
			$start = $pagesize * ($pagenum-1);
			$data['pubsearchlist'] = $this->cms_model->pubsearch($sid, $keyword, $pagenum, $pagesize, 0);
			
			$data['pubsearchcount'] = $this->cms_model->getpubsearchrecordcount($sid, $keyword, $pagesize);
			
			//pager			
			$pagecount = $this->cms_model->getpubsearchpagecount($sid, $keyword, $pagesize);	
			$pager = $this->cms_model->GetPagerHtml_PubSearch($pagenum,$pagecount);
			$data['pager'] = $pager;
		}
		else{
			$data['pubsearchlist'] = array();
			$data['pubsearchcount'] = 0;
			$data['pager'] = '';
		}
		
		$this->load->view('header_view',$data);
		$this->load->view('pubsearch_view',$data);
		$this->load->view('footer_view',$data);
	}
	
	public function artsbyclick(){
		$cid= $this->uri->segment(3);
		$pagenum = $this->uri->segment(4);
		
		//articles
		if(empty($pagenum))
			$pagenum = 1;
		$pagesize = 15;		
		$start = $pagesize * ($pagenum-1);		
		$articles = $this->cms_model->listartsbyclick($cid, $pagenum, $pagesize, 0);
		
		//pager
		$pagecount = $this->cms_model->getartpagecount($cid, $pagesize);
		$pager = $this->cms_model->GetPagerHtml_Click($pagenum,$pagecount);
		
		$output = "";
		$output .= "<table id='table-artsclick' width='94%' border='0' align='center' cellpadding='0' cellspacing='0'>";
		$i = 0;
		foreach ($articles as $key=>$value) {
			$i++;
			$output .= "<tr>";
			$output .= "<td width='25' height='28' align='center'>";
			if($i < 11 && $pagenum == 1)
				$output .= "<img src='/image/".$i.".gif' width='13' height='11' /></td>";
			else 
				$output .= "<img src='/image/ico-09.gif' /></td>";
				
			$output .= "<td align='left'><a href='".$key."' target='_blank'>".$value."</a></td>";			
			$output .= "</tr>";
		}
		$output .= "<tr><td colspan='2' >".$pager."</td></tr>";
		
		$output .= "</table>";
		
		echo($output);
	}
	
}
